package org.bbs.demo.common;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result {
    public static Result OK(){
        return new Result(true, BBSConstants.CODE_OK, null, null);
    }

    public static Result OK(String message){
        return new Result(true, BBSConstants.CODE_OK, message, null);
    }

    public static Result OK(Object data){
        return new Result(true, BBSConstants.CODE_OK, null, data);
    }

    public static Result OK(String message, Object data){
        return new Result(true, BBSConstants.CODE_OK, message, data);
    }

    public static Result err(int errCode, String message){
        return new Result(false, errCode, message, null);
    }

    public static Result err(int errCode, String message, Object data){
        return new Result(false, errCode, message, data);
    }

    private boolean success;    //是否成功
    private int code;           //编码：200 成功     500 业务失败    503 系统错误    520 未登录
    private String message;     //概述信息
    private Object data;        //后端向前端回送的数据
}
